Imports JS.Nativo.WinFormUI.Contable
Imports JS.Nativo.DTO.Contable

Namespace Controles

    Public Class ConceptoCtaCte

        <System.ComponentModel.Category("Apariencia")> _
        Public Property Texto() As String
            Get
                Return gpbConcepto.Text
            End Get
            Set(ByVal value As String)
                gpbConcepto.Text = value
            End Set
        End Property

        Private mConcepto As ConceptoCuentaCorrienteDTO
        <System.ComponentModel.Category("Datos")> _
        Public Property Concepto() As ConceptoCuentaCorrienteDTO
            Get
                Return mConcepto
            End Get
            Set(ByVal value As ConceptoCuentaCorrienteDTO)
                mConcepto = value
                If mConcepto Is Nothing Then
                    txtConcepto.Text = String.Empty
                Else
                    txtConcepto.Text = mConcepto.Descripcion
                End If
            End Set
        End Property

        <System.ComponentModel.DefaultValue(-1)> _
        Public Property IdConcepto() As Integer
            Get
                If Me.Concepto IsNot Nothing Then
                    Return Me.Concepto.IdConceptoCuentaCorriente
                Else
                    Return -1
                End If
            End Get
            Set(ByVal value As Integer)
                If value > 0 AndAlso (Me.Concepto Is Nothing OrElse (Me.Concepto IsNot Nothing AndAlso value <> Me.Concepto.IdConceptoCuentaCorriente)) Then
                    Me.Concepto = Agente.Contable.ObtenerConceptoCuentaCorriente(value)
                ElseIf value <= 0 Then
                    Me.Concepto = Nothing
                End If
            End Set
        End Property

        Private Sub butBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butBuscar.Click
            Try
                Dim conceptos As New frmBuscarConceptoCtaCte
                conceptos.ConceptoCuentaCorriente = Me.Concepto
                conceptos.ConceptosCuentaCorriente = Agente.Contable.ObtenerConceptosCuentaCorriente()
                If conceptos.ShowDialog() = DialogResult.OK Then
                    Me.Concepto = conceptos.ConceptoCuentaCorriente
                End If
            Catch ex As Exception
                MostrarErrorGrave(ex.Message)
            End Try
        End Sub
    End Class

End Namespace
